package com.job.Job;

import org.openqa.selenium.By;
/**
 * This class provide the common functionalities among all TDD Pages
 * eg. logout
 * 
 * @author sshyamala 
 */

public class TDDBasePage extends BasePage {

	/**
	 * Stop the performance capture, 
	 * this method will be invoked by all sub-classes no need to stop the timer on a per-class basis 
	 */
	protected void validate() {    	
    	stopPerformanceCapturePageLoaded();
	}
	public void deleteProject(String projectName) throws Exception
	{
		if(isElementPresent(xpathLocator("//li[@data-name='"+projectName+"']")))
		{
		/* 2.5 
		 * JavascriptExecutor  js=(JavascriptExecutor)driver;
		js.executeScript("$('li[data-name=\""+projectName+"\"] .bg-btn-b').addClass('btn-visible');");				//
		//js.executeScript("$('li[data-name=\"projectxyzabc12\"] .bg-btn-b').addClass('btn-visible');");
		waitForElementPreset(xpathLocator("//li[@data-name='"+projectName+"']/ul/li[2]/div/a"),2000);
		//js.executeScript("$('li[data-name=\"projectxyzabc12\"] ul li div a.dropdown-toggle').click();");
		js.executeScript("$('li[data-name=\""+projectName+"\"] ul li div a.dropdown-toggle').click();");*/
		//2.5 click(xpathLocator("//ul[@id='temp-dropdown']/li[4]/a"));	
		/*waitForElementPreset(xpathLocator("//body/div[1]/div/div/ul/li[1]/ul/li[2]/div/ul/li[3]/a"),2000);
		click(xpathLocator("//body/div[1]/div/div/ul/li[1]/ul/li[2]/div/ul/li[3]/a"));
		click(idLocator("confirm_ok"));*/
		click(xpathLocator("html/body/div[1]/div/div/ul/li[1]/ul/li[2]/div/a/i/img"));
		Thread.sleep(1000);
		//br.findElement(By.xpath("html/body/div[1]/div/div/ul/li[1]/ul/li[2]/div/a/i/img")).click();
		//findElement(By.linkText("Remove Project")).click();
		click(linktextLocator("Remove Project"));
	    Thread.sleep(1000);
	    //br.findElement(By.id("confirm_ok")).click();
	    click(idLocator("confirm_ok"));
		
		}
	}
	
	public void clickProjectsButton()
	{
		click(linktextLocator("Projects"));
	}
	/**
     * Click on the "Logout" link.
     */
	public void clickLogoutLink() { click(cssLocator("img.arrow-down-a-img")); 
	click(linktextLocator("Sign Out"));
	}
	
	
	/**
	 * Click Admin icon on the upper left
	 */
	public void goAdmin() { click(linktextLocator("Admin")); }
	public By cssLocator(String locator) {
		return By.cssSelector(locator);
	}
	public By xpathLocator(String locator){
		return By.xpath(locator);
	}
	public By classLocator(String locator){
		return By.className(locator);
	}
	public By idLocator(String locator){
		return By.id(locator);
	}
	public By linktextLocator(String locator){
		return By.linkText(locator);
	}
	public By partialLinkTextLocator(String locator){
		return By.partialLinkText(locator);
	}
	public By nameLocator(String locator){
		return By.name(locator);
	}
	public By tagNameLocator(String locator){
		return By.tagName(locator);
	}

}
